
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="">
        <meta name="author" content="billyn">
        <link rel="stylesheet" href="<?php echo Yii::app()->baseUrl . '/a_bootstrap/css/bootstrap.min.css' ?> "/>
        <link rel="stylesheet" href="<?php echo Yii::app()->baseUrl . '/a_bootstrap/css/bootstrap-responsive.min.css' ?>' "/>
        <link rel="stylesheet" href="<?php echo Yii::app()->baseUrl . '/a_bootstrap/css/unicorn.main.css' ?> "/>
        <link rel="stylesheet" href="<?php echo Yii::app()->baseUrl . '/a_bootstrap/css/unicorn.grey.css' ?> "/>
        <title><?php echo CHtml::encode($this->pageTitle); ?></title>
        <style>
            #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
            .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
        </style>
    </head>
    <body>
        <div id="ajax-loaderdiv" style="display: none;">
            <img src="<?php echo Yii::app()->request->baseUrl . '/images/ajax-loader.gif' ?>" class="ajax-loader">
        </div>
        <?php
        $displayName = Blyn::app()->getActiveSpace()->getName(BEntity::Name_DisplayName);
        $aControl = new BUIWXControl('aControl');
        $apps = Blyn::app()->getActiveSpace()->getApps();
        $activeApp = Blyn::app()->getActiveApp();
        $activeAppName = $activeApp->getName();
        $items = array();
        $item = array();
        foreach ($apps as $app) {

            $name = $app->getName();

            if ($name == 'SpaceEngine' || $name == 'BSpaceEngine') {
                $name = Yii::t('site', 'Home');
            } else {
                $name = Yii::t('site', $name);
            }

            if ($app->getId() != Blyn::app()->getCurrentUser()->getPersonalSpace()->getAppByName('BPersonalApp')->getId()) {
                //$item['url'] = $app->getUIManager()->getUrl(array('ajaxLink' => array('name' => $name)));
//                $themeControl = new BUIThemedControl($name);
                $control = new BUIControl($name);
                $item['url'] = $control->getAjaxLink($name, array(
                    'cooker' => 'BAEvent@showEventList',
                    'theme' => 'a_bootstrap',
                ));
//        $item['url'] = $app->getUIManager()->getAjaxLink();
                $item['label'] = $name;
                $item['active'] = '';

                if ($app->getId() == $activeApp->getId())
                    $item['active'] = 'active';

                array_push($items, $item);
            }
        }
        ?>
        <?php
        $homeControl = new BUIThemedControl('allApp');
        $homeUrl = $homeControl->getLinkUrl('Home', array(
            'cooker' => 'BAEventCooker@showEventList',
            'theme' => 'a_bootstrap',
        ));
        ?>
        <link rel="stylesheet" type="text/css"
              href="<?php echo Yii::app()->request->baseUrl; ?>/a_bootstrap/css/uniform.css" />
        <style>
            .appHome{
                left: 15px;
                overflow: hidden;
                position: relative;
                top: 14px;
            }
            .appHome a {
                margin-left: 25px;
                font-size: 24px;
                color: white;
            }
        </style>

        <div id="header">
            <h2 class="appHome"><a href="#"><?php echo $displayName; ?></a></h1>		
        </div>

        <div id="search">
            <input type="text" placeholder="搜索..." /><button type="submit" class="tip-right" title="搜索"><i class="icon-search icon-white"></i></button>
        </div>
        <div id="user-nav" class="navbar navbar-inverse">
            <ul class="nav btn-group">
                <li class="btn btn-inverse"><a title="" href="#"><i class="icon icon-share-alt"></i> <span class="text">登出</span></a></li>
            </ul>
        </div>

        <div id="sidebar">
            <ul>
                <?php
                if (Blyn::app()->getActiveApp()->getId() != Blyn::app()->getCurrentUser()->getPersonalSpace()->getAppByName('BPersonalApp')->getId()) {
                    ?>
                    <?php
                    foreach ($items as $item) {
                        ?>
                        <li class="<?php echo $item['active']; ?>">
                            <?php echo $item['url']; ?>
                        </li>  
                        <?php
                    }
                }
                ?>
            </ul>

        </div>
        <div id="content">
            <div id="content-header">
                <h1>欢迎使用<strong>比邻平台</strong></h1>
            </div>
            <div id="breadcrumb">
                <a href="#" title="<?php echo $displayName; ?>" class="tip-bottom"><i class="icon-home"></i> <?php echo $displayName; ?></a>
                <a href="#" class="current"><?php echo Yii::t('site', $activeAppName); ?></a>
            </div>
            <div class="container-fluid">
                <div class="row-fluid">
                    <?php echo $content; ?>

                </div>
                <div class="row-fluid">
                    <div id="footer" class="span12">
                        2015 &copy; <a href="http://www.billyn.net/" target="_blank">billyn</a>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl . '/a_bootstrap/js/jquery.min.js' ?>"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl . '/a_bootstrap/js/bootstrap.min.js' ?>"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl . '/a_bootstrap/js/jquery.uniform.js' ?>"></script>
        <script type="text/javascript" src="<?php echo Yii::app()->baseUrl . '/a_bootstrap/js/unicorn.tables.js' ?>"></script>
    </body>
</html>
